﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;
using System.IO;

namespace Gundam_2._0_Alpha.src
{
    public class ICreateMissionSelect: IAction
    {
        private string profileName;

        public ICreateMissionSelect(string profileName)
        {
            this.profileName = profileName;
        }

        public void DoAction(GameController gc)
        {
            LoadProfile(gc);

            int textPosXStart = 20, textPosYStart = 40,
                incrementY = 60;

            CreateMenuButtons menuCreator = new CreateMenuButtons();

            List<Button> buttonList = menuCreator.CreateButtons("save\\missionList.txt", textPosXStart, textPosYStart, incrementY, gc.P.MissionsUnlocked);
            foreach (TextButton b in buttonList)
            {
                if (b.ButtonName.Contains("1"))
                    b.ButtonAction = new MissionOneLoader();
                else
                    b.ButtonAction = new MissionOneLoader();
            }

            Stage missionMenu = new Stage( false);

            missionMenu.ButtonList = buttonList;

            gc.GameStages.Push(missionMenu);
        }

        private void LoadProfile(GameController gc)
        {
            string[] profileData = System.IO.File.ReadAllLines((Resources.PathToResource("save\\" + profileName + ".txt")));
            int i = 0;

            gc.P.MissionsUnlocked = int.Parse(profileData[i]);            
        }
    }
}
